<%@ page language="java" contentType="text/html;charset=UTF-8"
   	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript">
	function deleteVideo(vdo_id,page){
		if(confirm("Are you sure you want to delete this video file?")){
			window.location="delete_video.html?vdo_id="+vdo_id+"&page="+page;
		}	
	}

</script>
</head>
<body>
<center>

<h2>វីដេអូ</h2>
	<table border="0" cellpadding="0" cellspacing="0" width="95%" class="ContentText">
		<tr class="myuploadheader" align="center">
			<td width="8%" height="25">លេខ</td>	
			<td width="35%">ចំណងជើង</td>	
			<td width="35%">បរិយាយ</td>	
			<td width="22%">សកម្មភាព</td>
		</tr>
		<%
			String bgcolor="#EEE";
		%>
		<c:if test="${fn:length(data)>0}">
			<c:forEach var="x" begin="0" end="${fn:length(data)-1}" step="1" varStatus ="status">
				<%
					bgcolor=(bgcolor=="#EEE")?"#FFF":"#EEE";
				%>
					<c:if test="${x>=StartingRow && x<=EndingRow}">
						<tr bgcolor="<%=bgcolor%>" align="center">
							<td height="40" style="border-left:solid 1px #DDD; border-bottom:solid 1px #DDD;"><c:out value="${x+1}"/></td>
							<td align="left" class="newsTitle" style="padding-top:5px; line-height:20px; padding-bottom:5px ;border-left:solid 1px #DDD; border-bottom:solid 1px #DDD;padding-right: 4px; padding-left: 4px;">
							<a href="edit_video.html?vdo_id=${data[x].FILE_ID}">	
								<c:choose>
									<c:when test="${fn:length(data[x].FILE_TITLE)>=60}">
										<c:out value="${fn:substring(data[x].FILE_TITLE,0,60)}"/>...
									</c:when>
									<c:otherwise>
										<c:out value="${data[x].FILE_TITLE}"/>
									</c:otherwise>
								</c:choose>
							</a></td>
							<td align="left" style="border-left:solid 1px #DDD;line-height:20px; border-bottom:solid 1px #DDD;padding-right: 4px; padding-left: 4px;">
								<p align="left">
								<c:choose>
									<c:when test="${fn:length(data[x].FILE_DESC)>=60}">
										<c:out value="${fn:substring(data[x].FILE_DESC,0,60)}"/>...
									</c:when>
									<c:otherwise>
										<c:out value="${data[x].FILE_DESC}"/>
									</c:otherwise>
								</c:choose>
								</p>
							</td>
							<td style="border:solid 1px #DDD; border-top:solid 0px #DDD;"><a href="video_image.html?vdo_id=${data[x].FILE_ID}">រូបភាព</a><label style="color:#BBB;">|</label><a href="edit_video.html?vdo_id=${data[x].FILE_ID}">កែប្រែ</a><label style="color:#BBB;">|</label><label style="cursor: pointer; color:#0066FF;" onclick="deleteVideo('${data[x].FILE_ID}','${page}')">លុបចោល</label></td>
						</tr>
					</c:if>
			</c:forEach>
		</c:if>
		<c:if test="${fn:length(data)<=0}">
			<tr>
				<td align="center" colspan="4" height="30" valign="bottom"> No video available</td>
			</tr>
		</c:if>
			<tr>
		<td height="30" valign="middle" colspan="4">
		<c:if test="${PageCount>1}">
			<c:if test="${page>1}">
				<a href="myuploads.html?page=${page-1}">Previous</a>
			</c:if>
			<c:if test="${page<=1}">
				<label style="color: #333">Previous</label>
			</c:if>
			
				<c:forEach var="i" begin="1" end="${PageCount}" step="1" varStatus ="status">
					<c:if test="${i==page}">
						<b style="color: #333"><c:out value="${i}" /></b>
					</c:if>
					<c:if test="${i!=page}">
						<a href="myuploads.html?page=${i}"><c:out value="${i}" /></a>
					</c:if>
				</c:forEach>
				
			<c:if test="${page<PageCount}">
				<a href="myuploads.html?page=${page+1}">Next</a>
			</c:if>
			<c:if test="${page>=PageCount}">
				<label style="color: #333">Next</label>
			</c:if>
		</c:if>
		</td>
	</tr>
	<tr><td colspan="4" align="center" class="newsTitle"><a href="new_video.html">បញ្ចូលវីដេអូថ្មី</a></td></tr>
	</table>
</center>

</body>
</html>